package example05;
import java.awt.*;
import javax.swing.*;
import net.sf.jeppers.grid.*;

/**
 * @author <a href="mailto:grom@capsicumcorp.com">Cameron Zemek</a>
 */
public class SimpleGridDemo {
	static public void main(String[] args) {
		JGrid grid = new JGrid(4, 4);
		grid.setValueAt("Hello World!!!", 1, 1);
		
		DefaultSpanModel spanModel = (DefaultSpanModel) grid.getSpanModel();
		spanModel.addSpan(new CellSpan(1, 1, 2, 2));
		
		DefaultStyleModel styleModel = (DefaultStyleModel) grid.getStyleModel();
		CellStyle style = new DefaultCellStyle();
		style.setHorizontalAlignment(SwingConstants.CENTER);
		style.setVerticalAlignment(SwingConstants.CENTER);
		style.setBackgroundColor(Color.YELLOW);
		styleModel.setCellStyle(style, 1, 1);
		
		// Add grid to container
		JScrollPane scrollPane = new JScrollPane(grid);
		grid.setPreferredScrollableViewportSize(grid.getMaximumSize());
		
		// Display grid in window
		JFrame frame = new JFrame("Span Grid Demo");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(new BorderLayout());
		frame.getContentPane().add(scrollPane, BorderLayout.CENTER);		
		frame.pack();
		frame.show();
	}
}
